package com.zn.customer.controller;

import com.zn.customer.model.Customer;
import com.zn.customer.service.CustomerService;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/register.do")
public class CurstomerRegisterController {
    protected void dpPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        CustomerService service = new CustomerService();
        boolean result = service.register(username,password);
        if(result){
            //注册成功进入首页
            req.getRequestDispatcher("login.jsp").forward(req,resp);
        }else {
            //注册失败后回到注册页面
            req.getRequestDispatcher("register.jsp").forward(req,resp);
        }
    }
}
